package com.freewater.cargotracker.domain.model.voyage;

import org.apache.commons.lang3.Validate;

import java.io.Serializable;
import java.util.Objects;

/**
 * 航线编号
 */
public class VoyageNumber implements Serializable {

    private static final long serialVersionUID = 1L;

    private String number;

    public VoyageNumber(String number) {
        Validate.notNull(number, "number is required");
        this.number = number;
    }

    public String getIdString() {
        return this.number;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || this.getClass() != obj.getClass()) {
            return false;
        }
        final VoyageNumber other = (VoyageNumber) obj;
        return this.sameValueAs(other);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.number);
    }

    @Override
    public String toString() {
        return "VoyageNumber{" +
                "number='" + number + '\'' +
                '}';
    }

    boolean sameValueAs(VoyageNumber other) {
        return other != null && this.number.equals(other.number);
    }
}
